package com.jy.rhin.facade.ws.document.subscribe;

import com.jy.framework.base.utils.Serializer;
import com.jy.rhin.application.document.DocumentSubAndPubService;
import com.jy.rhin.config.NamespaceConstants;
import com.jy.rhin.support.aspect.AuditLog;
import lombok.extern.slf4j.Slf4j;
import org.oasis_open.docs.wsn.b_2.*;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.jws.WebService;

@Slf4j
@WebService(
        serviceName = "DocumentSubAndPubServer",
        portName = "DocumentSubAndPubPort",
        targetNamespace = NamespaceConstants.NS_B2,
        endpointInterface = "com.jy.rhin.facade.ws.document.subscribe.DocumentSubAndPub")
@Component
public class DocumentSubAndPubPortImpl implements DocumentSubAndPub {

    @Resource
    DocumentSubAndPubService documentSubAndPubService;

    /**
     * 文档订阅
     *
     * @param message
     * @return
     */
    @Override
    @AuditLog
    public SubscribeResponse documentSubscribe(Subscribe message) {
        log.info("Executing operation documentSubscribe:{}", Serializer.serialize(message));
        return documentSubAndPubService.documentSubscribe(message);
    }

    /**
     * 取消文档订阅
     *
     * @param message
     * @return
     */
    @Override
    @AuditLog
    public UnsubscribeResponse documentUnSubscribe(Unsubscribe message) {
        log.info("Executing operation documentUnSubscribe:{}", Serializer.serialize(message));
        return documentSubAndPubService.documentUnSubscribe(message);
    }

    /**
     * 暂停文档订阅
     *
     * @param message
     * @return
     */
    @Override
    @AuditLog
    public PauseSubscriptionResponse documentPauseSubscribe(PauseSubscription message) {
        log.info("Executing operation documentPauseSubscribe:{}", Serializer.serialize(message));
        return documentSubAndPubService.documentPauseSubscribe(message);
    }

    /**
     * 恢复文档订阅
     *
     * @param message
     * @return
     */
    @Override
    @AuditLog
    public ResumeSubscriptionResponse documentResumeSubscribe(ResumeSubscription message) {
        log.info("Executing operation documentResumeSubscribe:{}", Serializer.serialize(message));
        return documentSubAndPubService.documentResumeSubscribe(message);
    }

}
